package com.ruoyi.common.annotation;

import com.ruoyi.common.validator.TruncateSizeValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

@Documented
@Constraint(validatedBy = TruncateSizeValidator.class)
@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
public @interface TruncateSize {

    String message() default "String has been truncated to {max} characters";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    int max() default 16;

    @Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.PARAMETER })
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    @interface List {
        TruncateSize[] value();
    }
}